package team.pwy.service;

import jakarta.annotation.Resource;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import team.pwy.consts.RbmConsts;
import team.pwy.mapper.MemberMapper;

import java.util.Map;

@Component
public class MemberServiceImpl implements MemberService {

    @Resource
    private MemberMapper memberMapper;

    @RabbitHandler
    @RabbitListener(queues = RbmConsts.MEMBER_QUEUE)
    public void member(Map<String, Integer> maps){
         Integer userId =  maps.get("userId");
         Integer secId =  maps.get("secId");
         if (secId==0){
             memberMapper.addByUserId(userId);
         } else if (secId==1) {
             memberMapper.updateByUserId(userId);
         }else {
             memberMapper.updateStatus(userId);
         }
    }
}
